package com.hera.process.config.service.impl;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.hera.base.util.Constantes;
import com.hera.base.util.FiltroDTO;
import com.hera.process.config.dao.DynaformDao;
import com.hera.process.config.dao.FormFieldDao;
import com.hera.process.config.service.DynaformService;
import com.hera.process.form.domain.Dynaform;

@Service("dynaformservice")
public class DynaformServiceImpl implements DynaformService{

	static final Logger logger = Logger.getLogger(UserServiceImpl.class);
	
	@Autowired
	private DynaformDao dynaformdao;
	
	@Autowired 
	private FormFieldDao formFieldDao;
	
	@Override
	public Dynaform findById(Long id) {
		
		return dynaformdao.findOne(id);
	}

	@Override
	public void update(Dynaform entity) {
		
		dynaformdao.save(entity);
	}

	@Override
	public void save(Dynaform entity) {
		
		dynaformdao.save(entity);
	}

	@Override
	public void delete(Dynaform entity) {
		formFieldDao.deleteByProcess(entity.getIdProcess());
		
		dynaformdao.delete(entity);
	}

	@Override
	public List<Dynaform> findAll() {
		
		return dynaformdao.findAll();
	}

	@Override
	public List<Dynaform> findAll(FiltroDTO filtroDTO) {
		
		return dynaformdao.obtenerEntidadesPorFiltros(filtroDTO);
	}

	@Override
	public List<Dynaform> findStageByIdProcess(Long idProcess) {
		// TODO Auto-generated method stub
		return dynaformdao.findStageByIdProcess(idProcess);
	}

	@Override
	public List<Dynaform> findGridFormByIdProcess(Long idProcess) {
		// TODO Auto-generated method stub
		return dynaformdao.findTypeFormByProcess(Constantes.FORMTYPE.GRID, idProcess);
	}
	

}
